package dpatterns.observer.trademonster;

import java.util.HashMap;
import java.util.Map;

import dpatterns.observer.trademonster.pull.StockPublisher;
import dpatterns.observer.trademonster.push.Stock;
import dpatterns.observer.trademonster.push.StockData;

public class StockMonitor {

	public static void main(String[] args) {
		StockData stockData = new StockData();
		
		Map<String, Stock> stocks = new HashMap<String, Stock>();
		
		stocks.put("AAPL", new Stock("AAPL", "Apple Inc", 112.54, -0.40));
		stocks.put("GOOG", new Stock("GOOG", "Google Inc", 530.59, 1.09));
		stocks.put("MSFT", new Stock("MSFT", "Microsoft Corporation", 48.45, 0.98));
		stocks.put("ORCL", new Stock("ORCL", "Oracle Corporation", 46.01, 0.79));
		stocks.put("TSLA", new Stock("TSLA", "Tesla Motors Inc", 220.97, -0.73));
				
		StockPublisher publisher = new StockPublisher(stockData);
		
		System.out.println("\n-------------------------- STOCKS --------------------------\n");
		stockData.setStocks(stocks);
		publisher.display();
		System.out.println("\n-----------------------------------------------------------\n");
		
		System.out.println("\n-------------------------- STOCKS --------------------------\n");
		stocks.put("MSFT", new Stock("MSFT", "Microsoft Corporation", 49.50, 1.68));
		stockData.setStocks(stocks);
		publisher.display();
		System.out.println("\n-----------------------------------------------------------\n");
	}

}
